'use strict';

const Service = require('egg').Service;

class AddressService extends Service {
    //添加
    //ctx  app  service config  logger
    async add(username,phone,area,detail,num) {
        await this.app.mysql.query('insert into address (username,phone,area,detail,num) values (?,?,?,?,?)',[username,phone,area,detail,num])
    }
    //编辑
    async edit(username,phone,area,detail,num,id){
        await this.app.mysql.query('update address set username=?,phone=?,area=?,detail=?,num=? where id=?',[username,phone,area,detail,num,id])
    }
    //查询
    async list(){
        return await this.app.mysql.query('select * from address');
    }
    //删除
    async del(id){
        await this.app.mysql.query('delete from address where id=?',[id])
    }
}

module.exports = AddressService;
